<?php

/**
 * 就业方向控制器 用于收集数据
 * @date 2014/01/11
 * @author 马燕龙
 */
class EmployAction extends Action
{

    //添加
    public function add()
    {

        //检测是否开启
        $siteSetting = D('Setting')->getSiteSetting();
        if ($siteSetting['site_status'] != 1) {
            $this->error('亲，您想干嘛！', 'add', 1000);
            exit;
        }
        $type = I('type',1);

        $Employ = D('Employ');
        if($type == 1){
            $position = $Employ->position;
        }elseif($type == 2){
            $position = $Employ->uiPosition;
        }elseif($type == 3){
            $position = $Employ->h5Position;
        }elseif($type == 4){
            $position = $Employ->javaPosition;
        }
        //处理添加
        if (!empty($_POST)) {
            if ($Employ->create()) {
                $result = $Employ->add();
                if ($result) {
                    $this->success('添加成功！');
                } else {
                    $this->error('添加失败！');
                }
            } else {
                $this->error($Employ->getError());
            }
            exit;
        }

        //赋值并显示页面
        $gradeList = D('Grade')->getGradeList(2);
        $areaList = D('Area')->getAreaList(1);
        $this->assign('gradeList', $gradeList);
        $this->assign('areaList', $areaList);
        $this->assign('siteSetting', $siteSetting);
        $this->assign('education', $Employ->education);
        $this->assign('method', $Employ->method);
        $this->assign('position', $position);
        $this->assign('pay', $Employ->pay);
        $this->assign('leval', $Employ->leval);
        $this->assign('education', $Employ->education);
        $this->assign('status', $Employ->status);
        $this->assign('type', $Employ->type[$type]);
        $this->display();

    }

    //添加
    public function uiadd()
    {

        //检测是否开启
        $siteSetting = D('Setting')->getSiteSetting();
        if ($siteSetting['site_status'] != 1) {
            $this->error('亲，您想干嘛！', 'add', 1000);
            exit;
        }


        $Employ = D('Employ');

        //处理添加
        if (!empty($_POST)) {
            if ($Employ->create()) {
                $result = $Employ->add();
                if ($result) {
                    $this->success('添加成功！');
                } else {
                    $this->error('添加失败！');
                }
            } else {
                $this->error($Employ->getError());
            }
            exit;
        }

        //赋值并显示页面
        $gradeList = D('Grade')->getGradeList(2);
        $areaList = D('Area')->getAreaList(1);
        $this->assign('gradeList', $gradeList);
        $this->assign('areaList', $areaList);
        $this->assign('siteSetting', $siteSetting);
        $this->assign('education', $Employ->education);
        $this->assign('method', $Employ->method);
        $this->assign('position', $Employ->position);
        $this->assign('uiPosition', $Employ->uiPosition);
        $this->assign('pay', $Employ->pay);
        $this->assign('leval', $Employ->leval);
        $this->assign('education', $Employ->education);
        $this->assign('status', $Employ->status);
        $this->display();

    }

}